class PolymorphicDeliverables < ActiveRecord::Migration
  def self.up
    rename_column :deliverables, :iteration_id, :schedulable_id
    add_column :deliverables, :schedulable_type, :string

    #All existing deliverables are belong to 'Iteration' and
    #not to 'ToDo'
    Deliverable.find(:all).each do |deliverable|
      deliverable.schedulable_type = "Iteration"
      deliverable.save
    end
  end

  def self.down
    remove_column :deliverables, :schedulable_type
    rename_column :deliverables, :schedulable_id, :iteration_id
  end
end
